<template>
  <div class="card">
    <p id="un">账号：</p>
    <input id="username" v-model="username" />
    <p id="ps">密码：</p>
    <input id="password" v-model="password" />
    <button @click="login">登录</button>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      username: "1",
      password: "1",
    };
  },
  components: {},
  methods: {
    login() {
      axios
        .post("http://localhost:8000/login", {
            username: this.username,
            password: this.password,
        })
        .then((response) => {
          alert("请求成功", response.data.error_message,"token为",response.data.token);
        })
        .catch((error) => {
          alert("请求失败", error.message);
        });
    },
  },
};
</script>

<style>
#un,
#ps,
#username,
#password {
  font-size: 30px;
  size: 30px;
  padding: 20px;
}
button {
  color: aqua;
  size: 30px;
  padding: 20px;
  font-size: 30px;
}
</style>
